package com.hare.system_api.vo;

import cn.hutool.core.collection.CollectionUtil;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: Hare
 * @description: 菜单下拉树列表
 * @author: Hare
 * @create: 2022-12-28 15:36
 * @Version 6.0.1
 **/
@Data
public class MenuTreeVO {

    /**
     * 唯一标识
     */
    private String id;

    /**
     * 指定节点标签为节点对象的某个属性值
     */
    private String label;

    /**
     * 指定子树为节点对象的某个属性值
     */
    private List<MenuTreeVO> children;


    public MenuTreeVO() {
    }

    public MenuTreeVO(SysMenuVO sysMenuVO) {
        this.id = sysMenuVO.getId();
        this.label = sysMenuVO.getMenuName();
        if(CollectionUtil.isNotEmpty(sysMenuVO.getChildren())){
            this.children = sysMenuVO.getChildren().stream().map(MenuTreeVO::new).collect(Collectors.toList());
        }
    }
}
